package Item
{
	import Map.CMapTile;
	
	import flash.display.Sprite;
	
	import srdk.SRAABB;
	
	public class CItem
	{
		public static const TYPE_FOOD		:uint = 0;
		public static const TYPE_VIRUS		:uint = 1;
		public static const TYPE_COIN		:uint = 2;
		public static const TYPE_GOLD		:uint = 3;
		public static const TYPE_SHOWTIME	:uint = 4;
		public static const TYPE_COUNT		:uint = 5;
		
		protected static const TIME_DESTROY_FOOD		:Number = 25.0;
		protected static const TIME_DESTROY_COIN		:Number = 6.0;
		protected static const TIME_DESTROY_GOLD		:Number = 3.0;
		protected static const TIME_DESTROY_SHOWTIME	:Number = 7.0;
		protected static const TIME_DESTROY_VIRUS		:Number = 7.0;
		
		private var m_nType :uint;
		
		protected var m_sprite :Sprite;
		protected var m_aabb :SRAABB;
		
		protected var m_nMapPosX :int;
		protected var m_nMapPosY :int;
		protected var m_bIsDestroy :Boolean;
		protected var m_nDestroyElapsedTime :Number;
		
		public function get nType() :uint { return m_nType; }
		public function get sprite() :Sprite { return m_sprite; }
		public function get aabb() :SRAABB { return m_aabb; }
		public function get nMapPosX() :int { return m_nMapPosX; }
		public function get nMapPosY() :int { return m_nMapPosY; }
		public function get bIsDestroy() :Boolean { return m_bIsDestroy; }
		
		public function CItem(nType :uint)
		{
			m_nType = nType;
			
			m_aabb = new SRAABB();
			m_aabb.width = CMapTile.TILE_WIDTH;
			m_aabb.height = CMapTile.TILE_HEIGHT;
			
			m_bIsDestroy = false;
			m_nDestroyElapsedTime = 0;
		}
		public function SetMapPosition(nMapPosX :int, nMapPosY :int) :void
		{
			m_nMapPosX = nMapPosX;
			m_nMapPosY = nMapPosY;
			
			m_sprite.x = nMapPosX*CMapTile.TILE_WIDTH + CMapTile.TILE_WIDTH/2;
			m_sprite.y = nMapPosY*CMapTile.TILE_HEIGHT + CMapTile.TILE_HEIGHT/2;
			UpdateAABB();
		}
		public function Update(tick :Number) :void {}
		private function UpdateAABB() :void
		{
			m_aabb.SetPosition(m_sprite.x, m_sprite.y);
		}

	}
}